home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
examples.zoo
/
numberth
/
stirling.lsp
< prev
Wrap
Lisp/Scheme
|
1991-10-22
|
1KB
|
54 lines
;; Ausrechnen der Doppelfolge der Stirling-Zahlen
;; Bruno Haible 28.1.1990
(provide 'stirling)
(require 'intmisc) ; Macro defun-N0
;; Stirling-Zahlen 2. Art S(n,k)
; liefert zu n>=0 einen Array #(stirling2(n,0) ... stirling2(n,n))
(defun-N0 stirling2-table (n)
(if (= n 0)
(vector '1)
(let ((A_n-1 (stirling2-table (1- n)))
(A_n (make-array (1+ n))))
(do ((i 0 (1+ i)))
((> i n))
(setf (aref A_n i)
(+ (if (> i 0) (aref A_n-1 (1- i)) 0)
(* i (if (< i n) (aref A_n-1 i) 0))
) ) )
A_n
) ) )
; S(n,k) für ganze Zahlen n, k
(defun stirling2 (n k)
(if (<= 0 k n) (aref (stirling2-table n) k) 0)
)
;; Stirling-Zahlen 1. Art s(n,k)
; liefert zu n>=0 einen Array #(stirling1(n,0) ... stirling1(n,n))
(defun-N0 stirling1-table (n)
(if (= n 0)
(vector '1)
(let* ((n-1 (1- n))
(A_n-1 (stirling1-table n-1))
(A_n (make-array (1+ n))))
(do ((i 0 (1+ i)))
((> i n))
(setf (aref A_n i)
(- (if (> i 0) (aref A_n-1 (1- i)) 0)
(* n-1 (if (< i n) (aref A_n-1 i) 0))
) ) )
A_n
) ) )
; s(n,k) für ganze Zahlen n, k
(defun stirling1 (n k)
(if (<= 0 k n) (aref (stirling1-table n) k) 0)
)